%{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "y.tab.h"

int line_n=1;
%}

%%
and						{ return TK_AND; }
or						{ return TK_OR; }
if 						{ return TK_IF; }
then					{ return TK_THEN; }
else 					{ return TK_ELSE; }
endif 					{ return TK_ENDIF; }
do 						{ return TK_DO; }
while 					{ return TK_WHILE; }
loop 					{ return TK_LOOP; }
do[ ]case	 			{ return TK_DOCASE; }
end[ ]case 				{ return TK_ENDCASE; }
case					{ return TK_CASE; }
other					{ return TK_OTHER; }
declare 				{ return TK_DECLARE; }
enddeclare 				{ return TK_ENDDECLARE; }
out						{ return TK_OUT; }
roundeven				{ return TK_ROUNDEVEN; }
int						{ return TK_TD_INT; }
float					{ return TK_TD_FLOAT; }
string					{ return TK_TD_STRING; }
[a-zA-Z_][a-zA-Z0-9_-]*	{ yylval.sval = yytext; return TK_ID; }
[0-9]+					{ yylval.ival = atoi(yytext); return TK_INT; }
[0-9]+,[0-9]*			{ yylval.fval = atof(yytext); return TK_FLOAT; }
[0-9]*,[0-9]+			{ yylval.fval = atof(yytext); return TK_FLOAT; }
\"[ \|\°\¬\!\"\#\$\%\&\/\(\)\=\?\¡\'\¿\\\¸\´\+\¨\*\~\{\}\[\]\^\`\-\_\.\:\,\;\<\>a-zA-Z0-9]*\"	{ return TK_STRING; }
##[ \|\°\¬\!\"\#\$\%\&\/\(\)\=\?\¡\'\¿\\\¸\´\+\¨\*\~\{\}\[\]\^\`\-\_\.\:\,\;\<\>a-zA-Z0-9]*		{ return TK_COMMENT; }
\-						{ return TK_MINUS; }
\+						{ return TK_PLUS; }
\*						{ return TK_MULTIPLY; }
\/						{ return TK_DIVIDE; }
=						{ return TK_ASSIGN; }
!						{ return TK_NOT; }
\>						{ return TK_GREATERTHAN; }
\<						{ return TK_LESSTHAN; }
\(						{ return TK_OBRACKET; }
\)						{ return TK_EBRACKET; }
\[						{ return TK_OSQBRACKET; }
\]						{ return TK_ESQBRACKET; }
\:						{ return TK_COLLON; }
\,						{ return TK_COMMA; }
\n						{ ++line_n; return TK_ENDL; }
[ \t]+					/* ignore whitespace */;
%%